package com.bbm.controller;


import com.bbm.entity.Comment;
import com.bbm.entity.vo.ResponseResult;
import com.bbm.service.CommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Comment)表控制层
 *
 * @author lionkliu
 * @since 2024-02-18 18:03:31
 */
@RestController
@RequestMapping("comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return commentService.selectPage(pageNum,pageSize);
    }

    @GetMapping("{id}")
    public ResponseResult getCommentByHouseId(@PathVariable Integer id) {
        return commentService.getCommentByHouseId(id);
    }
    @PostMapping
    public ResponseResult insert(@RequestBody Comment comment) {
        return commentService.insertOne(comment);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Comment comment) {
        return commentService.updateOne(comment);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return commentService.deleteById(id);
    }

}
